cd /Users/kyy/lib

function kill_process(){
    echo "will find and kill process $1"
    ps -ef | grep $1 | grep -v grep |  awk '{print $2}' | xargs kill -9
}

case $1 in
start)
    echo "start nacos"
    sh ./nacos/bin/startup.sh -m standalone &
    echo "start zipkin"
    java -jar ./zipkin.jar &
    echo "start sentinel-dashboard"
    java -Dserver.port=8080 -Dcsp.sentinel.dashboard.server=localhost:8080 -Dproject.name=sentinel-dashboard -jar ./sentinel-dashboard.jar &
;;
stop)
    echo "stop sentinel-dashboard"
    kill_process "sentinel-dashboard.jar"
    echo "stop zipkin"
    kill_process "zipkin.jar"
    echo "stop nacos"
    sh ./nacos/bin/shutdown.sh
;;
*)
    echo "$1 is an invalid option"
;;
esac